#include "AABB.h"
#include <math.h>

#define POS_INF	1e10

AABB::AABB(void)
{
	p0 = Vec2d(POS_INF, POS_INF);
	p1 = -1.0 * p0;
}

AABB::AABB( Vec2d p0, Vec2d p1 )
{
	this->p0 = p0;
	this->p1 = p1;
}


AABB::~AABB(void)
{
}

void AABB::Expand( Vec2d p )
{
	p0 = Vec2d(min(p0[0], p[0]), min(p0[1], p[1]));
	p1 = Vec2d(max(p1[0], p[0]), max(p1[1], p[1]));
}

bool AABB::Contains( Vec2d p )
{
	return p0[0] <= p[0] && p0[1] <= p[1] && p1[0] >= p[0] && p1[1] >= p[1];
}
